/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.eng.scc.core.details;

import com.eng.scc.core.data.Address;
import com.eng.scc.core.data.Company;
import com.eng.scc.core.db.manager.service.FuelControllerManagerService;
import com.eng.scc.core.util.HTMLFactory;
import com.eng.scc.core.view.ApplicationContext;

/**
 *
 * @author Rafael
 */
public class CompanyDetails
{
    public static HTMLFactory.Body getDetails( Company comp )
    {
        HTMLFactory.Body body = new HTMLFactory.Body();
        
        try
        {
            HTMLFactory.Title title = new HTMLFactory.Title( "Empresa: " + comp.getFantasyName() );
            
            body.addContent( title );
            
            HTMLFactory.TableDetails details = new HTMLFactory.TableDetails();
            
            details.addItem( "Nome", comp.getRealName() );
            details.addItem( "Nome Fantasia", comp.getFantasyName() );
            details.addItem( "CNPJ", comp.getCnpj(), true );
            
            Address address = FuelControllerManagerService.getInstance().getAddress( comp.getAddressId() );
            
            if ( address != null )
            {
                details.addItem( "Estado", FuelControllerManagerService.getInstance().getHomeState( address.getHomeState() ).getName() );
                details.addItem( "Cidade", FuelControllerManagerService.getInstance().getCity( address.getCityId() ).getName() );
                details.addItem( "CEP", address.getCep() );
                details.addItem( "Endereço", address.getName() );
                details.addItem( "Nº", address.getNumber() );
            }
            
            details.addItem( "Email", comp.getEmail() );
            details.addItem( "Telefone Principal", comp.getPhone1(), true );
            details.addItem( "Telefone Adicional", comp.getPhone2(), true );
            
            body.addContent( details );
        }
        catch ( Exception e )
        {
            ApplicationContext.getInstance().saveLog( e );
        }
        
        return body;
    }
}
